define(['vue'],
  function (Vue) {
    function render() {
      new Vue({
        el: '#tmzk_test',
        methods: {
          async onlyoffice() {
            const projectBaseId = '999'
            const fileName = '项目结算书.doc'
            const downloadUrl = await $.elApi.projectBaseWordFileInfo.onlyOfficePath({ id: projectBaseId, fileName })
            let origin = location.origin
            if (location.hostname === 'localhost') {
              origin = 'http://10.0.16.132:8090'
            }
            const onlyofficeCallbackUrl = `${origin}/tmzk/v1/api/online/office/callback?projectBaseId=${projectBaseId}&fileName=${fileName}`
            $.onlyOffice.open({
              //可选edit或者view
              action: 'edit',
              file: {
                id: projectBaseId,
                // 文件名称
                name: fileName
              },
              // 文件地址
              downloadUrl: downloadUrl,
              //编辑回调地址
              onlyofficeCallbackUrl: onlyofficeCallbackUrl,
              // 关闭回调
              cancel: () => {
                // todo
              }
            })
          },
        }
      })
    }
    return {
      init: render
    }
  })